package mka.puzzle.util;

import java.util.Random;

import mka.puzzle.shape.SimpleCircle;
import mka.puzzle.shape.SimpleRectangle;
import mka.puzzle.shape.SimpleShapeList;
import mka.puzzle.shape.SimpleSquare;

/***
 * FunctionShape
 * @version 20131124
 * 
 * @author NguyenBB
 */
public class FunctionShape {

	/**
	 * addRandomShape
	 * 
	 * Add Shape (0: Rectangle, 1: Square, 2: Circle)
	 * 
	 * @param list
	 */
	public static void addRandomShape(SimpleShapeList list) {
		int choose = randNumber(3);
		if (choose == 0) {
			list.addShape(new SimpleRectangle(randNumber(10), randNumber(10)));
		} else if (choose == 1) {
			list.addShape(new SimpleSquare(randNumber(10)));
		} else {
			list.addShape(new SimpleCircle(randNumber(10)));
		}
	}

	/**
	 * createRandomShapeList
	 * 
	 * Add Shape (0: Rectangle, 1: Square, 2: Circle)
	 * 
	 * @param list
	 * @return ShapeList
	 */
	public static SimpleShapeList createRandomShapeList(int numberList) {
		int choose = randNumber(3);
		SimpleShapeList list = new SimpleShapeList();

		for (int i = 0; i < numberList; i++) {
			if (choose == 0) {
				list.addShape(new SimpleRectangle(randNumber(10), randNumber(10)));
			} else if (choose == 1) {
				list.addShape(new SimpleSquare(randNumber(10)));
			} else {
				list.addShape(new SimpleCircle(randNumber(10)));
			}
		}

		return list;
	}

	/**
	 * createRandomShape
	 * 
	 * Create Shape (0: Rectangle, 1: Square, 2: Circle)
	 * @return 
	 * 
	 * @return Shape
	 */
	public static Object createRandomShape() {
//		Shape shape;
		int choose = randNumber(3);
		if (choose == 0) {
			return new SimpleRectangle();
		} else if (choose == 1) {
			return new SimpleSquare();
		} else {
			return new SimpleCircle();
		}
	}

	/**
	 * randNumber
	 * 
	 * Generate random number base input param
	 * 
	 * @param number
	 *            int
	 * @return int
	 */
	public static int randNumber(int number) {
		return new Random().nextInt(number);
	}
}
